//
//  SelectLabelImageCell.m
//  QuXiang
//
//  Created by Duncan on 2020/6/22.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import "SelectLabelImageCell.h"

@implementation SelectLabelImageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.clipsToBounds = YES;
        [self.contentView addSubviews:[NSArray arrayWithObjects:self.leftLabel, self.rightLabel, self.rightImage, self.leftImage, nil]];
        [self masonryLayout];
    }
    return self;
}

- (void)wealthCenterMasLayout {
    self.leftImage.hidden = NO;
    self.leftLabel.textColor = [UIColor whiteColor];
    self.rightLabel.textColor = [UIColor whiteColor];
    [self.leftImage mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(13));
        make.centerY.equalTo(self.contentView);
        make.size.mas_equalTo(kFragmemtFloat(23));
    }];
    [self.leftLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftImage.mas_right).offset(kFragmemtFloat(16));
        make.centerY.equalTo(self.contentView);
        make.width.mas_equalTo(kScreen_Width / 2);
    }];
}



#pragma mark ------- Lazy Methods -------

- (void)masonryLayout {
    [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(13));
        make.centerY.equalTo(self.contentView);
        make.size.mas_equalTo(kFragmemtFloat(23));
    }];
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(15));
        make.centerY.equalTo(self.contentView);
        make.width.mas_equalTo(kScreen_Width / 2);
    }];
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(15));
        make.centerY.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(kFragmemtFloat(7), kFragmemtFloat(12)));
    }];
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.rightImage.mas_left).offset(-kFragmemtFloat(10));
        make.centerY.equalTo(self.contentView);
        make.width.mas_equalTo(kScreen_Width / 2);
    }];
}

- (UIImageView *)leftImage {
    if (!_leftImage) {
        _leftImage = [[UIImageView alloc] init];
        _leftImage.hidden = YES;
        _leftImage.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _leftImage;
}

- (UILabel *)leftLabel {
    if (!_leftLabel) {
        _leftLabel = [[UILabel alloc] init];
        _leftLabel.textColor = [UIColor blackColor];
        [_leftLabel setFont:kAdaptedFontSize(15)];
    }
    return _leftLabel;
}

- (UILabel *)rightLabel {
    if (!_rightLabel) {
        _rightLabel = [[UILabel alloc] init];
        _rightLabel.textColor = [UIColor blackColor];
        _rightLabel.textAlignment = NSTextAlignmentRight;
        [_rightLabel setFont:kAdaptedFontSize(15)];
    }
    return _rightLabel;
}

- (UIImageView *)rightImage {
    if (!_rightImage) {
        _rightImage = [[UIImageView alloc] initWithImage:@"base_next_gray".image];
    }
    return _rightImage;
}

@end
